from django.db import models

# Create your models here.
from django.db import models
from department.models import Department

class Teacher(models.Model):
    """教师"""
    name = models.CharField(max_length=100, verbose_name='姓名')
    sex = models.BooleanField(default=1, verbose_name='性别')
    title = models.CharField(max_length=50, blank=True, verbose_name='职称')
    department = models.ForeignKey(Department, on_delete=models.CASCADE,
                                   related_name='teachers',
                                   verbose_name='所属系部')
    created_at = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')

    class Meta:
        db_table = 'tb_teacher'
        verbose_name = '教师'
        verbose_name_plural = verbose_name

    def __str__(self):
        return f'{self.name}({self.department.name})'